<template>
  <div class="demo">
    <div class="demo-title">位置</div>
    <div class="demo-content">
      <div :style="{ marginLeft: `${buttonWidth}px`, whiteSpace: 'nowrap' }">
        <Popconfirm placement="topLeft" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">TL</Button>
        </Popconfirm>
        <Popconfirm placement="top" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">Top</Button>
        </Popconfirm>
        <Popconfirm placement="topRight" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">TR</Button>
        </Popconfirm>
      </div>
      <div :style="{ width: `${buttonWidth}px`, float: 'left' }">
        <Popconfirm placement="leftTop" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">LT</Button>
        </Popconfirm>
        <Popconfirm placement="left" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">Left</Button>
        </Popconfirm>
        <Popconfirm placement="leftBottom" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">LB</Button>
        </Popconfirm>
      </div>
      <div :style="{ width: `${buttonWidth}px`, marginLeft: `${buttonWidth * 4 + 24}px` }">
        <Popconfirm placement="rightTop" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">RT</Button>
        </Popconfirm>
        <Popconfirm placement="right" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">Right</Button>
        </Popconfirm>
        <Popconfirm placement="rightBottom" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">RB</Button>
        </Popconfirm>
      </div>
      <div :style="{ marginLeft: `${buttonWidth}px`, clear: 'both', whiteSpace: 'nowrap' }">
        <Popconfirm placement="bottomLeft" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">BL</Button>
        </Popconfirm>
        <Popconfirm placement="bottom" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">Bottom</Button>
        </Popconfirm>
        <Popconfirm placement="bottomRight" ok-text="Yes" cancel-text="No" @confirm="confirm">
          <template #title>
            <p>{{ text }}</p>
            <p>{{ text }}</p>
          </template>
          <Button class="button">BR</Button>
        </Popconfirm>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import Message from '@sscd/message';
  import Button from '@sscd/button';
  import Popconfirm from '@sscd/popconfirm';
  const buttonWidth = 70;
  const text = 'Are you sure to delete this task?';
  const confirm = () => Message.info('Clicked on Yes.');
</script>
<style lang="less" scoped>
  .demo {
    padding-top: 120px;
    .button {
      width: 70px;
      margin: 0 0 8px 8px;
    }
  }
</style>
